#include <iostream>
#include <cassert>

#include "solver.hpp"

using namespace std;
using namespace sv;


int main(int argc, char* argv[])
{
	Model mdl;
	
	Var* vars = mdl.addVars(3, VarType::INTEGER);

	mdl.addConstr(2 * vars[0] + vars[1], ConstrOper::LESS_EQUAL, 10);
	mdl.addConstr(3 * vars[0] + 6 * vars[1], ConstrOper::LESS_EQUAL, 40);
	mdl.addConstr(3 * vars[0] + 6 * vars[1] + 4 * vars[2], ConstrOper::LESS_EQUAL, 50);
	mdl.setObjective(100 * vars[0] + 150 * vars[1] + 120 * vars[2], MDL_MAXIMIZE);

	switch(mdl.optimize()) {
	case OPTIMAL:			
		cout << "OPTIMAL SOLUTION: " << mdl.get(DoubleAttr::Obj) << endl; 
		for (int i = 0; i < mdl.get(IntAttr::NumVars); i++) {
			cout << "var[" << i << "] : " << vars[i].get(DoubleAttr::X) << endl;
		}
		break;
	case INFEASIBLE:	
		cout << "INFEASIBLE MODEL" << endl;					
		break;
	case UNBOUNDED:	
		cout << "UNBOUNDED SOLUTION" << endl;			
		break;
	default:
		assert(false);
	}
	return 0;
}
